package com.feiyue.learning;

/**
 * StringBuffer 是 final 类, 其实例对象指向的内存地址不可变，但是指向的地址中的内容是可以变
 * @author  feiyue
 * @date  2020/4/1
 */
public class StringBufferTest {

    public static void main(String[] args) {
        StringBuffer A = new StringBuffer("A");
        StringBuffer B = new StringBuffer("B");
        Person C = new Person(3);
        operate(A, B, C);

        // 结果是 ？
        System.out.println(A + "," + B + "," + C.getAge());
    }

    private static void operate(StringBuffer a, StringBuffer b, Person c) {
        a.append(b);
        b = a;
        c = new Person(5);
    }

    static class Person {
        int age;

        public Person(int age) {
            this.age = age;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }
    }
}
